package com.syni.mdd.yhd.common.all.controller.protect;

/**
 * @className BmsBusinessController
 * @description TOO
 * @Author cfx
 * @DATE 2019/4/15 14:25
 * @VERSION 1.0
 **/
import com.syni.mdd.yhd.common.all.constants.ResultCode;
import com.syni.mdd.yhd.common.all.entity.bo.user.CheckUserBo;
import com.syni.mdd.yhd.common.all.service.search.BmsSearchService;
import com.syni.mdd.sjb.common.component.utils.common.utils.ParamsMap;
import com.syni.mdd.yhd.common.all.utils.RequestParamUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/search")
public class BmsSearchController {
    @Autowired
    BmsSearchService bmsSearchService;

    /**
     * @Description 联动匹配
     * @Author: cfx
     * @Date: 2019/9/25
     */
    @PostMapping("/match")
    public Map<String,Object> match(@RequestBody ParamsMap paramsMap){
        return bmsSearchService.match(paramsMap);
    }

    /**
     * @Description 搜索类型匹配
     * @Author: cfx
     * @Date: 2019/9/25
     */
    @PostMapping("/typeMatch")
    public Map<String,Object> typeMatch(@RequestBody ParamsMap paramsMap){
        paramsMap.put("userId",null);
        CheckUserBo checkUserBo = RequestParamUtils.checkUserBo();
        //默认使用设备标识
        if(checkUserBo.getCheckStatus().equals(ResultCode.CODE_NORMAL)){
            paramsMap.put("userId",checkUserBo.getUserId());
        }
        return bmsSearchService.typeMatch(paramsMap);
    }
}
